package com.issac.demo.pooled2.mypool;

/**
 * @author: ywy
 * @date: 2023-06-28
 * @desc:
 */
public class Person implements Runnable {

    private MyPool<ShareBike> myPool;

    public Person(MyPool<ShareBike> myPool) {
        this.myPool = myPool;
    }

    @Override
    public void run() {
        for (int i = 0; i < 10000; i++) {
            try {
                ShareBike shareBike = myPool.borrowObject(ShareBike.class);
                System.out.println(shareBike);
                myPool.returnObject(shareBike);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
